package com.cake.liulanxiangzhu.web;

import com.github.pagehelper.PageInfo;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class JsonPage<T> implements Serializable {
    //总页数
    private Integer totalPages;
    //总条数
    private Long totalCount;
    //当前页码
    private Integer page;
    //分页条数
    private Integer pageSize;
    //分页数据
    private List<T> list ;


    public static <T>JsonPage<T> restPage(PageInfo<T> pageInfo){
        JsonPage<T> result = new JsonPage<>();
        result.setTotalPages(pageInfo.getPages());
        result.setTotalCount(pageInfo.getTotal());
        result.setPage(pageInfo.getPages());
        result.setPageSize(pageInfo.getPageSize());
        result.setList(pageInfo.getList());
        return result;

    }


}
